<template>
  <div class="mod-menu">
    <el-form :inline="true" :model="pamars">
      <el-form-item label="单品名称">
        <el-input v-model="pamars.title" placeholder="单品名称" clearable></el-input>
      </el-form-item>
      <el-form-item label="单品编号">
        <el-input v-model="pamars.code" placeholder="单品编号" clearable></el-input>
      </el-form-item>

      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" row-key="Id" border style="width: 100%; ">
      <el-table-column prop="cover_image" align="center" label="单品图片">
        <template slot-scope="scope">
          　　　　<el-popover placement="top-start" trigger="click">
            <a :href="scope.row.cover_image" target="_blank" title="查看最大化图片"><img :src="scope.row.cover_image" style="width: 300px;height: 300px" /></a>
            <img slot="reference" :src="scope.row.cover_image" @click="$openImg(scope.row.cover_image)" style="width: 50px;height: 50px; cursor:pointer" />
          </el-popover>
          <div>{{scope.row.single_goods_title}}</div>
          　　
        </template>
      </el-table-column>
      <el-table-column prop="title" align="center" label="名称">
      </el-table-column>

      <el-table-column prop="code" align="center" label="单品编号">
      </el-table-column>

      <el-table-column prop="buy_num" align="center" label="购买数量">
      </el-table-column>
      <el-table-column prop="single_goods_num" align="center" label="当前库存">
      </el-table-column>

      <el-table-column prop="update_time" align="center" label="时间">
      </el-table-column>
    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pamars.page" :page-sizes="[10, 20, 50, 100]" :page-size="pamars.limit" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
  </div>
</template>

<script>
import seviceApi from '@/api/serviceApi.js'
export default {
  data () {
    return {
      dataForm: {},
      pamars: {
        page: 1,
        limit: 10,
        title: null,
        code: null

      },
      totalPage: 0,
      dataList: [],

      dataListLoading: false
    }
  },
  components: {
  },
  mounted () {
    this.getList()
  },
  methods: {
    // 获取列表
    getList () {
      seviceApi.getOutStockrecordList(this.pamars).then(res => {
        if (res && res.data.code == 200) {
          this.dataList = res.data.page.list
          this.totalPage = res.data.page.totalCount
        }
      })
    },

    // 每页数
    sizeChangeHandle (val) {
      this.pamars.limit = val
      this.getList()
    },
    // 当前页
    currentChangeHandle (val) {
      this.pamars.page = val
      this.getList()
    },
    // 查询
    getDataList () {
      this.pamars.page = 1
      this.getList()
    }

  }
}
</script>
